package com.dqhl.community.activity;

import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;

import com.dqhl.community.R;
import com.dqhl.community.base.BaseActivity;

/**
 * Created by guanlucoang on 2016/8/30.
 * 预缴费 activity
 */
public class PropertyPredictActivity extends BaseActivity implements View.OnClickListener {
    private String type;
    private TextView tv_topTitle, tv_propertyType;
    private ImageView iv_topBack;
    private String strMoney;
    //    private TextView tv_money;
    private TextView tv_total;
    private EditText et_predict_money;
    private Button btn_payConfim;
    private String total;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_property_predict);
        initView();
        initData();
    }

    private void initView() {
        strMoney = getIntent().getStringExtra("total");
        tv_topTitle = (TextView) findViewById(R.id.tv_top_title);
        tv_topTitle.setText("预交缴费");
        iv_topBack = (ImageView) findViewById(R.id.iv_top_back);
        iv_topBack.setVisibility(View.VISIBLE);
        tv_propertyType = (TextView) findViewById(R.id.tv_propertyType);
//        tv_money = (TextView) findViewById(R.id.tv_money);
//        tv_money.setText(strMoney);
        tv_total = (TextView) findViewById(R.id.tv_total);
//        tv_total.setText("￥" + strMoney);
        btn_payConfim = (Button) findViewById(R.id.btn_payConfim);
        btn_payConfim.setOnClickListener(this);
        et_predict_money = (EditText) findViewById(R.id.et_predict_money);
        et_predict_money.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {

            }

            @Override
            public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
                total = "￥" + et_predict_money.getText().toString();
                tv_total.setText(total);
            }

            @Override
            public void afterTextChanged(Editable editable) {

            }
        });
    }

    private void initData() {
        iv_topBack.setOnClickListener(this);
        type = getIntent().getStringExtra("rentalType");
        if ("1".equals(type)) {
            tv_propertyType.setText("物业费");
        } else if ("2".equals(type)) {
            tv_propertyType.setText("水费");
        } else if ("3".equals(type)) {
            tv_propertyType.setText("电费");
        } else if ("4".equals(type)) {
            tv_propertyType.setText("卫生费");
        } else if ("5".equals(type)) {
            tv_propertyType.setText("燃气费");
        } else if ("6".equals(type)) {
            tv_propertyType.setText("电梯费");
        }
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.iv_top_back:
                finish();
                break;
            case R.id.btn_payConfim: //确认支付
                break;
        }
    }
}
